<template>
  <el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="cancel" :visible.sync="dialog" :title="isAdd ? '新增' : '编辑'" width="500px">
    <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
      <el-form-item label="客户编号" >
        <el-input v-model="form.custNum" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="客户名称" >
        <el-input v-model="form.custName" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="证件类型" >
        <el-input v-model="form.credentialType" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="证件编号" >
        <el-input v-model="form.credentialNum" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="客户类型" >
        <el-input v-model="form.custType" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="客户状态" >
        <el-input v-model="form.custStatus" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="客户经理" >
        <el-input v-model="form.accountManagerName" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="管理机构" >
        <el-input v-model="form.managerDept" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="所属行业" >
        <el-input v-model="form.industry" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="所属支行" >
        <el-input v-model="form.subBranch" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="组织机构代码" >
        <el-input v-model="form.deptCode" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="产业结构调整类型" >
        <el-input v-model="form.industrialAdjustType" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="客户规模（行内）" >
        <el-input v-model="form.customerScaleIn" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="注册地" >
        <el-input v-model="form.registPlace" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="注册地是否县级以上" >
        <el-input v-model="form.isRegistOverCounty" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="行业门类分类" >
        <el-input v-model="form.industryKind" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="行业门类大类" >
        <el-input v-model="form.industryBigKind" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="行业门类中类" >
        <el-input v-model="form.industryMidKind" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="行业门类小类" >
        <el-input v-model="form.industrySmallKind" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="从业人数" >
        <el-input v-model="form.jobPeopleNum" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="营业收入" >
        <el-input v-model="form.businessIncome" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="营业总额" >
        <el-input v-model="form.businessSale" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="台账状态" >
        <el-input v-model="form.ledgerStatus" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="实际经营地址" >
        <el-input v-model="form.realBusinessAddr" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="省份" >
        <el-input v-model="form.province" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="地级市" >
        <el-input v-model="form.preLevelCity" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="风险等级" >
        <el-input v-model="form.riskLevel" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="成立日期" >
        <el-input v-model="form.foundDate" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否出口型" >
        <el-input v-model="form.isExportType" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否进口型" >
        <el-input v-model="form.isImportType" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="法人代表" >
        <el-input v-model="form.legalRepresent" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="实际控制人" >
        <el-input v-model="form.realController" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="客户与我行关联关系" >
        <el-input v-model="form.custBankRelationship" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="建立信贷关系时间" >
        <el-input v-model="form.buildCreditTime" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否龙头企业" >
        <el-input v-model="form.isLeadingEnterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否高新技术企业" >
        <el-input v-model="form.isHighTechEnterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否支持科技创新企业" >
        <el-input v-model="form.isSupportNewTechEnterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否支持节能减排企业" >
        <el-input v-model="form.isSupportEnergySaveEnterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否三农企业" >
        <el-input v-model="form.isFarmerEnterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否十大振新企业" >
        <el-input v-model="form.isTop10Enterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否高科技产业" >
        <el-input v-model="form.isHighTechIndustry" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否支持民生领域企业" >
        <el-input v-model="form.isSupportPeopleEnterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否异地贷款" >
        <el-input v-model="form.isOtherPlaceLoan" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否西咸新区企业" >
        <el-input v-model="form.isXixianEnterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="社会环境风险分类" >
        <el-input v-model="form.societyRiskKind" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否优势企业" >
        <el-input v-model="form.isSuperiorityEnterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否产能落后" >
        <el-input v-model="form.isCapacityBack" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否国家宏观调控行业" >
        <el-input v-model="form.isNationalMacroCtrlIndustry" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否支持农田水利建设" >
        <el-input v-model="form.isSupportWaterFarmland" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否工业转型升级标注用户" >
        <el-input v-model="form.isIndustrialTransformCust" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="涉农类型" >
        <el-input v-model="form.relateFarmType" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否战略新兴产业" >
        <el-input v-model="form.isStrategicNewIndustry" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否淘汰落后产能企业" >
        <el-input v-model="form.isEliminateBackEnterprises" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否一带一路企业" >
        <el-input v-model="form.isOneWayEnterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否高污染高耗能企业" >
        <el-input v-model="form.isHighPollutionEnterprises" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否政府合作类企业" >
        <el-input v-model="form.isGovernentCoopEnterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="是否科技型企业" >
        <el-input v-model="form.isTechnologyEnterprise" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="企业类别划分" >
        <el-input v-model="form.enterpriseClassify" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="导入日期" >
        <el-input v-model="form.importDate" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="维护人账号" >
        <el-input v-model="form.maintainer" style="width: 370px;"/>
      </el-form-item>
      <el-form-item label="各户经理账号" >
        <el-input v-model="form.accountManager" style="width: 370px;"/>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="text" @click="cancel">取消</el-button>
      <el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { add, edit } from '@/api/custComBaseinfo'
export default {
  props: {
    isAdd: {
      type: Boolean,
      required: true
    }
  },
  data() {
    return {
      loading: false, dialog: false,
      form: {
        id: '',
        custNum: '',
        custName: '',
        credentialType: '',
        credentialNum: '',
        custType: '',
        custStatus: '',
        accountManagerName: '',
        managerDept: '',
        industry: '',
        subBranch: '',
        deptCode: '',
        industrialAdjustType: '',
        customerScaleIn: '',
        registPlace: '',
        isRegistOverCounty: '',
        industryKind: '',
        industryBigKind: '',
        industryMidKind: '',
        industrySmallKind: '',
        jobPeopleNum: '',
        businessIncome: '',
        businessSale: '',
        ledgerStatus: '',
        realBusinessAddr: '',
        province: '',
        preLevelCity: '',
        riskLevel: '',
        foundDate: '',
        isExportType: '',
        isImportType: '',
        legalRepresent: '',
        realController: '',
        custBankRelationship: '',
        buildCreditTime: '',
        isLeadingEnterprise: '',
        isHighTechEnterprise: '',
        isSupportNewTechEnterprise: '',
        isSupportEnergySaveEnterprise: '',
        isFarmerEnterprise: '',
        isTop10Enterprise: '',
        isHighTechIndustry: '',
        isSupportPeopleEnterprise: '',
        isOtherPlaceLoan: '',
        isXixianEnterprise: '',
        societyRiskKind: '',
        isSuperiorityEnterprise: '',
        isCapacityBack: '',
        isNationalMacroCtrlIndustry: '',
        isSupportWaterFarmland: '',
        isIndustrialTransformCust: '',
        relateFarmType: '',
        isStrategicNewIndustry: '',
        isEliminateBackEnterprises: '',
        isOneWayEnterprise: '',
        isHighPollutionEnterprises: '',
        isGovernentCoopEnterprise: '',
        isTechnologyEnterprise: '',
        enterpriseClassify: '',
        importDate: '',
        maintainer: '',
        accountManager: ''
      },
      rules: {
      }
    }
  },
  methods: {
    cancel() {
      this.resetForm()
    },
    doSubmit() {
      this.loading = true
      if (this.isAdd) {
        this.doAdd()
      } else this.doEdit()
    },
    doAdd() {
      add(this.form).then(res => {
        this.resetForm()
        this.$notify({
          title: '添加成功',
          type: 'success',
          duration: 2500
        })
        this.loading = false
        this.$parent.init()
      }).catch(err => {
        this.loading = false
        console.log(err.response.data.message)
      })
    },
    doEdit() {
      edit(this.form).then(res => {
        this.resetForm()
        this.$notify({
          title: '修改成功',
          type: 'success',
          duration: 2500
        })
        this.loading = false
        this.$parent.init()
      }).catch(err => {
        this.loading = false
        console.log(err.response.data.message)
      })
    },
    resetForm() {
      this.dialog = false
      this.$refs['form'].resetFields()
      this.form = {
        id: '',
        custNum: '',
        custName: '',
        credentialType: '',
        credentialNum: '',
        custType: '',
        custStatus: '',
        accountManagerName: '',
        managerDept: '',
        industry: '',
        subBranch: '',
        deptCode: '',
        industrialAdjustType: '',
        customerScaleIn: '',
        registPlace: '',
        isRegistOverCounty: '',
        industryKind: '',
        industryBigKind: '',
        industryMidKind: '',
        industrySmallKind: '',
        jobPeopleNum: '',
        businessIncome: '',
        businessSale: '',
        ledgerStatus: '',
        realBusinessAddr: '',
        province: '',
        preLevelCity: '',
        riskLevel: '',
        foundDate: '',
        isExportType: '',
        isImportType: '',
        legalRepresent: '',
        realController: '',
        custBankRelationship: '',
        buildCreditTime: '',
        isLeadingEnterprise: '',
        isHighTechEnterprise: '',
        isSupportNewTechEnterprise: '',
        isSupportEnergySaveEnterprise: '',
        isFarmerEnterprise: '',
        isTop10Enterprise: '',
        isHighTechIndustry: '',
        isSupportPeopleEnterprise: '',
        isOtherPlaceLoan: '',
        isXixianEnterprise: '',
        societyRiskKind: '',
        isSuperiorityEnterprise: '',
        isCapacityBack: '',
        isNationalMacroCtrlIndustry: '',
        isSupportWaterFarmland: '',
        isIndustrialTransformCust: '',
        relateFarmType: '',
        isStrategicNewIndustry: '',
        isEliminateBackEnterprises: '',
        isOneWayEnterprise: '',
        isHighPollutionEnterprises: '',
        isGovernentCoopEnterprise: '',
        isTechnologyEnterprise: '',
        enterpriseClassify: '',
        importDate: '',
        maintainer: '',
        accountManager: ''
      }
    }
  }
}
</script>

<style scoped>

</style>
